package homework10package;

import java.util.ArrayList;
import java.io.*;
import java.net.URL;
import redis.clients.jedis.*;
import java.util.HashSet;


/**
 * test_urlreader class
 * 
 * this class tests the functionality of the urlreader class
 * 
 * @author      Elizabeth Mahon and Orion Taylor (added comments)
 * @course Software Engineering
 * @date 3-10-13
 */

public class test_urlreader
{
	/** function main
	 * 
	 * main tests the functionality of the readURL function of the
	 * urlreader class
	 * 
	 * @param args: command line arguments
	 * @return void: this function returns nothing
	 * @throws IOException 
	 * @throws ClassNotFoundException 
	 */
	public static void main(String[] args) throws IOException, ClassNotFoundException{
		
		//create a urlread object associated with "http://www.serebii.net"
		urlreader q = new urlreader("http://www.serebii.net");
		
		//output_string is the non html content on this webpage
		String output_string=q.getpage_content();
		
		//so print it out to the terminal
		System.out.println(output_string+"\n");
		
		
		//URL_list is a list of all the URL's on this webpage
		ArrayList<URL> URL_list=q.getURL_list();
		
		//iterate through it and print out each one
		for(URL e_string:URL_list){
			System.out.println(e_string);
		}
		
		
		//print out the word_freq variable to see if it is working properly
		System.out.println(q.getword_freq());
		
		byte[] serialization= q.serialize();
		urlreader p=new urlreader();
		urlreader new_q=p.deserialize(serialization);
		
		System.out.println(new_q.getlocal_URL().equals(
				q.getlocal_URL().toString()));
		
		System.out.println(new_q.getpage_content().equals(
				q.getpage_content().toString()));
		
		System.out.println(new_q.getURL_list().toString().equals(
				q.getURL_list().toString()));

		
		System.out.println(new_q.getword_freq().toString().equals(
				q.getword_freq().toString()));
		
		System.out.println(new_q.getword_freq());
		System.out.println(q.getword_freq());
		
	}
}
